package com.tvsinfo.suanfa;

public class Demo4 {
    public static void main(String[] args) {
        String str="Convenience vs health: the takeaway dilemma";
        Demo4 demo4=new Demo4();
        demo4.todoMethod(str);
    }




    public int[] todoMethod(String str){
        char[] ch=str.toCharArray();
        int zg=0,kg=0,sg=0,qg=0;
        for(int i = 0 ; i < ch.length; i++){
            if(ch[i] >=65 && ch[i] <= 90 || ch[i] >= 97 && ch[i] <= 122){
                zg++;
            }else if(ch[i] == ' '){
                kg++;
            }else if(ch[i] >= 48 && ch[i] <= 57){
                sg++;
            }else{
                qg++;
            }
        }
        System.out.println("英文字母有"+zg+"个，"+"空格的个数有"+kg+"个，"+"数字的个数有"+sg+"个,"+"其它字符有"+qg+"个。");
        int[] count=new int[4];
        count[0]=zg;
        count[1]=kg;
        count[2]=sg;
        count[3]=qg;
        return count;
    }
}
